<?

class osFujixerox {
	public $id = 'fujixerox';
	public $tabs = array(
		'interfaces'=>'Interfaces'
	
	);
	public $device;
	public function __construct(&$device=null) {
		$this->device = $device;
	}
	
	public $snmpSections = array(
		'HOST-RESOURCES-MIB',
		'IF-MIB',
		'SNMPv2-MIB'
	);

	public $dataCollectors = array(
		'getProcessorLoads',
		'getMemoryUsage',
		'getSystemLoad',
		'setProcessesUsersUptimeRrd'
	);

	public function getResources() {
		// Device Information
		foreach ($this->device->snmp->find('HOST-RESOURCES-MIB','hrDeviceIndex') AS $key=>$index) {
			$item = $this->device->snmp->find('HOST-RESOURCES-MIB','hrDevice([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			switch (substr($item['hrDeviceType'],strrpos(':',$item['hrDeviceType']))) {
				case 'hrDeviceProcessor':
					$this->device->cpus[]  = new objProcessor($item);
					break;
			}
		}		
		// Storage/Memory Information
		foreach ($this->device->snmp->find('HOST-RESOURCES-MIB','hrStorageIndex') AS $key=>$index) {
			$item = $this->device->snmp->find('HOST-RESOURCES-MIB','hrStorage([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			switch (substr($item['hrStorageType'],strrpos(':',$item['hrStorageType']))) {
				case 'hrStorageRam':
				case 'hrStorageVirtualMemory':
					$this->device->memory[$index] = new objMemory($item);
					break;
				case 'hrStorageFixedDisk':
					$this->device->storage[$index] = new objStorage($item);
					break;
					
			}
		}
		// Network Interface Information
		foreach ($this->device->snmp->find('IF-MIB','^ifIndex.([0-9]+)') AS $key=>$index) {
			$item = $this->device->snmp->find('IF-MIB','^if([a-zA-z0-9]+).'.$index,true);
			$item = $item[$index];
			$item['device_id'] = $this->device->id;
			$interface = new objInterface($item);
			$this->device->interfaces[$index] = $interface;
		}	
		
	
	
	
	}
	public function getUptime() { return $this->device->snmp->get('HOST-RESOURCES-MIB','hrSystemUptime.0');}
	
	
	public function checkDescription($sysDescr='') {
		return preg_match("/^FUJI XEROX/", $sysDescr)?$this->id:'';
	}
	public function getType() {
		$sysDescr = $this->device->snmp->get('SNMPv2-MIB','sysDescr.0');
		if (preg_match("/C525/", $sysDescr)) {
			return $this->device->os_type.'-c525';		
		} else return $this->device->os_type;
	}
	public function getDescription() { 
		$output = array();
		foreach (explode(';',$this->device->snmp->get('SNMPv2-MIB','sysDescr.0')) AS $part) {
			foreach (explode(',',$part) AS $subPart) {
				$output[] = $subPart;
			}
		}
		return implode('<br/>',$output);
	}
}


?>